import React from 'react'
import { Form,Table, Icon, Tag, Modal, Steps, Button, message,Input,Row,Col,Select,DatePicker,InputNumber } from 'antd'
import { DropOption } from 'components'

const Step = Steps.Step;
const confirm = Modal.confirm
const FormItem = Form.Item;
const Option = Select.Option;

class ModalSelect extends React.Component {
 constructor(props) {
    super(props);
    this.state = {
    		type:'',
    		businessType:'',
    		createUser:'',
    		title:'',
    		strTime:'',
    		endTime:'',
				auditState:'',
				
				
    };
  }

	searchLeave(){
		const params = {
	      	type:this.state.type,  //档案类型
			businessType:this.state.businessType,  //业务类型
			createUser:this.state.createUser,  //管理人
			title:this.state.title,   //档案标题
			startTime:this.state.strTime,  //开始时间
			endTime:this.state.endTime,    //结束时间
			auditState:this.state.auditState,  //档案状态
//			operatingState:this.props.menu,   //0申请  1审批  2我提交的  3已审批 
//			operatingType:0,  //0归档  1变更  2销毁
	    };
	    if(this.state.createUser == ''){
	    		delete params.createUser
	    }
	    if(this.state.type == ''){
	    		delete params.type
	    }
	    if(this.state.businessType == ''){
	    		delete params.businessType
	    }
	    if(this.state.title == ''){
	    		delete params.title
	    }
	    if(this.state.strTime == ''){
	    		delete params.startTime
	    }
	    if(this.state.endTime == ''){
	    		delete params.endTime
	    }
	    if(this.state.auditState == ''){
	    		delete params.auditState
	    }
//	    console.log(params)
	    this.props.onSearch(params);
	}
	typeChange(value) {
		this.setState({type:`${value}`})
	}
	businesChange(value){
		this.setState({businessType:`${value}`})
	}
	strTimeChange(date, dateString){
		this.setState({ strTime: dateString });
	}
	endTimeChange(date, dateString){
		this.setState({ endTime: dateString });
	}
	userChange(event){
		this.setState({createUser:event.target.value})
	}
	stateChange(value){
		this.setState({auditState:`${value}`})
//		console.log(event)
//		console.log(`${value}`)
//		this.setState({title:event.target.value})
	}
	titleChage(event){
		this.setState({title:event.target.value})
	}
	componentDidMount(){
		const { onSearch,pagination1 } = this.props
		const params = {
			page:pagination1.current
		}
		onSearch(params)
	}
	render(){
		const {getFieldDecorator,getFieldsValue}=this.props.form
		const {depTypes,userList} = this.props
//		console.log(depTypes)
//		console.log(userList)
		const typeChild = [];
		if(depTypes != undefined){
		    for (let i = 0; i < depTypes.length; i++) {
			  typeChild.push(<Option key={depTypes[i].name}>{depTypes[i].name}</Option>);
			}	
		}
		const userChild = [];
		if(userList != undefined){
		    for (let i = 0; i < userList.length; i++) {
			  userChild.push(<Option key={userList[i].username}>{userList[i].username}</Option>);
			}	
		}		
		const formItemLayout = {
	      labelCol: { span: 6 },
	      wrapperCol: { span:18 },
	    };
	    const formItemLayout1 = {
	      labelCol: { span: 3 },
	      wrapperCol: { span:21 },
	    };
		const { current } = this.state;
		return (
	      <Form style={{border:"1px dashed #e1e1e1",borderRadius:4,paddingTop:20,marginBottom:20
	      	//margin:" 0 20px",border:" 1px dashed",borderRadius: 5,marginRight:10
	      }}>
	    <span style={{marginLeft:20,fontWeight:600}}>查询条件</span>
        <Row style={{marginTop:10}} gutter={24} span={24}>
          <Col lg={6} md={3} sm={4} xs={6} push={1} style={{ marginBottom: 16 }}>
            <span>档案类型:&nbsp;&nbsp;</span>
            <Select
              placeholder="请选择档案类型"
              style={{ width: 200 }}
              onChange={this.typeChange.bind(this)}
            >
              {/*{typeChild}*/}
              <Option value="档案类型1">档案类型1</Option>
              <Option value="档案类型2">档案类型2</Option>
              <Option value="档案类型3">档案类型3</Option>
            </Select>
          </Col>

          <Col lg={6} md={3} sm={4} xs={6} style={{ marginBottom: 16 }}>
            <span>业务类型:&nbsp;&nbsp;</span>
            <Select
              style={{ width: 200 }}
              placeholder="请选择业务类型"
              onChange={this.businesChange.bind(this)}
            >
              <Option value="业务类型1">业务类型1</Option>
              <Option value="业务类型2">业务类型2</Option>
              <Option value="业务类型3">业务类型3</Option>
            </Select>
          </Col>
          
         <Col lg={6} md={3} sm={4} xs={6} style={{ marginBottom: 16 }}>
            <span>审核状态:&nbsp;&nbsp;</span>
            <Select
              style={{ width: 200 }}
              placeholder="请选择审核状态"
              onChange={this.stateChange.bind(this)}
            >
              <Option value="0">申请中</Option>
              <Option value="1">通过</Option>
              <Option value="2">拒绝</Option>
            </Select>
          </Col>
          
          <Col lg={6} md={3} sm={4} xs={6} style={{ marginBottom: 16 }}>
            <span>管理人员:&nbsp;&nbsp;</span>
            <Input
              placeholder="请输入档案标题关键字"
              onChange={this.userChange.bind(this)}
              style={{ width: 200 }}
            />
          </Col>
          
          <Col lg={6} md={3} sm={4} xs={6} push={1} style={{ marginBottom: 16 }} >
            <span>开始日期:&nbsp;&nbsp;</span>
            <DatePicker
              style={{ width: 200 }}
              placeholder="开始日期"
              onChange={this.strTimeChange.bind(this)}
              showTime
              format="YYYY-MM-DD HH:00:00"
            />
          </Col>

          <Col lg={6} md={3} sm={4} xs={6} style={{ marginBottom: 16 }}>
            <span>结束日期:&nbsp;&nbsp;</span>
            <DatePicker
              style={{ width: 200 }}
              placeholder="结束日期"
              onChange={this.endTimeChange.bind(this)}
              showTime
              format="YYYY-MM-DD HH:00:00"
            />
          </Col>
         
          <Col lg={6} md={3} sm={4} xs={6} style={{ marginBottom: 16 }}>
            <span>档案标题:&nbsp;&nbsp;</span>
            <Input
              placeholder="请输入档案标题关键字"
              onChange={this.titleChage.bind(this)}
              style={{ width: 200 }}
            />
          </Col>           
   		  <Col lg={24} md={12} sm={16} xs={24} style={{ marginBottom: 16,textAlign:"center" }}>
            <Button
              style={{ marginLeft: 10,width:200,height:30 }}
              type="primary"
              size="default"
              onClick={this.searchLeave.bind(this)}
            >
              查询
            </Button>
          </Col>
 
        </Row>
            
      </Form>
	  	)
}
  

}

export default Form.create()(ModalSelect)
